package com.example.readroomforpaging3.network

import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

object NetworkCreator {

    private val retrofit: Retrofit by lazy {
        Retrofit.Builder()
            .baseUrl("https://www.wanandroid.com/")
            .addConverterFactory(GsonConverterFactory.create())
            .build()
    }

    private inline fun <reified T> create(): T = retrofit.create(T::class.java)

    val articleApi by lazy {
        create<ArticleApi>()
    }

    suspend fun getArticlePage(page: Int) = articleApi.getArticlePage(page).data

}